﻿<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" %>
<%@ Import Namespace="SoftwareMonkeys.Scriptech.Web" %>
<%@ Import Namespace="SoftwareMonkeys.Scriptech.Diagnostics" %>
<script runat="server">
		public string ReferringScript = String.Empty;

		private void Page_Load(object sender, EventArgs e)
		{
			ReferringScript = Request.QueryString["ReferringScript"];
		}

		private string GetCreateUrl()
		{
			string url = String.Empty;
		
			using (LogGroup logGroup = LogGroup.StartDebug("Creating the URL to edit the problematic script."))
			{
				string editPage = WebUtilities.MapUrlPath("/EditScript.aspx");
				
				string queryStrings = "?Script=" + ReferringScript;
				
				if (Request.Url.Query.Length > 0)
				{
					queryStrings = queryStrings + "&" + Request.Url.Query.Substring(Request.Url.Query.IndexOf("&")+1,
						Request.Url.Query.Length-Request.Url.Query.IndexOf("&")-1);
				}
				
				url = editPage + queryStrings;
				
				LogWriter.Debug("URL: " + url);
			}
			return url;
		}
</script>
<asp:Content ID="BodyContent" ContentPlaceHolderID="Body" runat="server">
<h1>Script Not Found</h1>

<p>
<a href='<%= WebUtilities.MapUrlPath("/") %>'>Home</a>
</p>
<p>Script doesn't exist: <%= ReferringScript %></p>
<p>
	<a href='<%= GetCreateUrl() %>'>Create script &raquo;</a>
</p>
<p>
	<a href='javascript:history.go(-1);'>&laquo; Back (Previous Page)</a>
</p>
</asp:Content>
